package com.mark.musicbox;

import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.SimpleAdapter.ViewBinder;

public class ActivityGroupMain extends ActivityGroup implements
		View.OnClickListener {
	LinearLayout container = null;
	ImageView btnModuleMusic = null;
	ImageView btnModulePlay = null;
	ImageView btnModuleDownload = null;
	LocalActivityManager m;
	Window w = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.groupmain);
		m = getLocalActivityManager();
		container = (LinearLayout) findViewById(R.id.InnerContainer);
		btnModuleMusic = (ImageView) findViewById(R.id.btnModuleMusic);
		btnModulePlay = (ImageView) findViewById(R.id.btnModulePlaying);
		btnModuleDownload = (ImageView) findViewById(R.id.btnModuleDownload);
		Intent intent = new Intent();
		btnModuleMusic.setOnClickListener(this);
		btnModulePlay.setOnClickListener(this);
		btnModuleDownload.setOnClickListener(this);
		intent.setClass(ActivityGroupMain.this, ActivityModuleMusic.class);
		Window w = m.startActivity("InnerActivity1", intent);
		container.addView(w.getDecorView());

	}

	public void onClick(View v) {
		Intent intent = new Intent();
		switch (v.getId()) {
		case R.id.btnModuleMusic:
			btnModuleMusic.setImageResource(R.drawable.tab_music_default);
			btnModulePlay.setImageResource(R.drawable.tab_playing_press);
			btnModuleDownload.setImageResource(R.drawable.tab_download_press);
			intent.setClass(ActivityGroupMain.this, ActivityModuleMusic.class);
			Window w = m.startActivity("InnerActivity1", intent);
			container.removeAllViews();
			container.addView(w.getDecorView());
			break;

		case R.id.btnModulePlaying:
			btnModuleMusic.setImageResource(R.drawable.tab_music_press);
			btnModulePlay.setImageResource(R.drawable.tab_playing_default);
			btnModuleDownload.setImageResource(R.drawable.tab_download_press);
			intent.setClass(ActivityGroupMain.this, ActivityMusicList.class);
			w = getLocalActivityManager().startActivity("InnerActivity2",
					intent);
			container.removeAllViews();
			container.addView(w.getDecorView(), LayoutParams.FILL_PARENT,
					LayoutParams.FILL_PARENT);
			break;

		case R.id.btnModuleDownload:
			btnModuleMusic.setImageResource(R.drawable.tab_music_press);
			btnModulePlay.setImageResource(R.drawable.tab_playing_press);
			btnModuleDownload.setImageResource(R.drawable.tab_music_default);
			intent.setClass(ActivityGroupMain.this,
					ActivityModuleDownload.class);
			w = m.startActivity("InnerActivity3", intent);
			container.removeAllViews();
			container.addView(w.getDecorView(), LayoutParams.FILL_PARENT,
					LayoutParams.FILL_PARENT);
			break;

		}

	}

}
